package iscte.ai.kcgtd;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ViewAdapter extends BaseAdapter {

		private String [] options;
		private int []  optionsIcons;
		private int itemLayout;
		private Activity activity;
		
		public ViewAdapter(Activity activity,int itemLayout,String [] options, int [] optionsIcons) {
			super();
			this.options = options;
			this.optionsIcons = optionsIcons;
			this.itemLayout = itemLayout;
			this.activity = activity;
		}
		
		@Override
		public int getCount() {
			return options.length;
		}

		@Override
		public String getItem(int position) {
			return options[position];
		}

		@Override
		public long getItemId(int position) {
			return 0;
		}
	
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			LayoutInflater inflator = activity.getLayoutInflater();
			convertView = inflator.inflate(itemLayout, null);
			TextView text = (TextView) convertView.findViewById(R.id.category_item_project_textview);
			ImageView image = (ImageView) convertView.findViewById(R.id.category_item_project_imageview);
			text.setText(options[position]);
			image.setImageResource(optionsIcons[position]);
			
			return convertView;
		}
		
	}


